import { delToken, getToken, setToken } from "@/utils/storage"
import { getUser } from '@/api/user'

export default {
    namespaced: true,
    state () {
        return {
            token: getToken(),
            userInfo: {},
        }
    },
    mutations: {
        setUserToken (state, payload) {
            state.token = payload
            setToken(payload)
        },
        outLogin (state) {
            state.token = null
            delToken()
        },
        updateUserInfo(state, payLoad){
            state.userInfo = payLoad
        },
    },
    actions: {
        async getUserList(ctx) {
            const res = await getUser()
            ctx.commit('updateUserInfo', res.data)
        }
    },
    getters: {
        
    }
}